package com.example.ftp.util;

import java.io.IOException;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.ftp.FTPClient;

public abstract class FTPClientUtil {
	public static void connect(FTPClient ftpClient, String host, String port) throws IOException{
		
		if (StringUtils.isNotBlank(host)){
			
			if (StringUtils.isNotBlank(port)){
				ftpClient.connect(host, Integer.parseInt(port));
			} else {
				ftpClient.connect(host);
			}
		}
	}
	
	public static void close(FTPClient ftpClient) throws IOException{
		if (ftpClient != null){
			ftpClient.logout();
			ftpClient.disconnect();
		}
	}
}